<ol class="breadcrumb">
    <li><a href="#">系统中心</a></li>
    <li>角色管理</li>
</ol>
<div class="panel panel-default">
    <div class="panel-heading">
        <span class="icon-group icon-large"></span>
        <span class="panel-title">角色列表</span>
        <% if(session.permissionMap[2007]){ %>
        <a href="/user/role/to/create" class="pull-right btn btn-success btn-sm" style="margin-top: -3px;">
            <span class="glyphicon glyphicon-plus"></span>
            <span>新增</span>
        </a>
        <% } %>
    </div>
    <div class="table-responsive">
        <table class="table table-hover table-striped">
            <thead>
            <tr>
                <th width="90%">角色名称</th>
                <th>操作</th>
            </tr>
            </thead>
            <tfoot>
            <tr>
                <td colspan="7">
                    <nav class="twbsPagination"></nav>
                </td>
            </tr>
            </tfoot>
            <tbody>
            <% roles.forEach(function(role, index){ %>
            <tr>
                <td><%= role.name %></td>
                <td>
                    <% if(session.permissionMap[2009]){ %>
                    <a class="btn btn-sm btn-default" href="/user/role/to/edit/<%= role._id %>">编辑</a>
                    <% } %>
                    <% if(session.permissionMap[2008]){ %>
                    <a class="btn btn-sm btn-danger" href="/user/role/remove/<%= role._id %>"
                       onclick="return confirm('确定删除该角色?')">删除</a>
                    <% } %>
                </td>
            </tr>
            <% }); %>
        </table>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        //分页功能
        $('.twbsPagination').twbsPagination({
            totalPages: <%= pages %>,
            visiblePages: 10,
            href: '/user/role/list?num={{number}}'
        });
    })
</script>